package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.AsysStudentBenefitExchange;
import com.ruoyi.system.service.IAsysStudentBenefitExchangeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 学生作业减免权益兑换记录Controller
 *
 * @author 杨佳霖
 * @date 2025-08-29
 */
@RestController
@RequestMapping("/system/exchange")
public class AsysStudentBenefitExchangeController extends BaseController
{
    @Autowired
    private IAsysStudentBenefitExchangeService asysStudentBenefitExchangeService;

    /**
     * 查询学生作业减免权益兑换记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:exchange:list')")
    @GetMapping("/list")
    public TableDataInfo list(AsysStudentBenefitExchange asysStudentBenefitExchange)
    {
        startPage();
        List<AsysStudentBenefitExchange> list = asysStudentBenefitExchangeService.selectAsysStudentBenefitExchangeList(asysStudentBenefitExchange);
        return getDataTable(list);
    }

    /**
     * 导出学生作业减免权益兑换记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:exchange:export')")
    @Log(title = "学生作业减免权益兑换记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AsysStudentBenefitExchange asysStudentBenefitExchange)
    {
        List<AsysStudentBenefitExchange> list = asysStudentBenefitExchangeService.selectAsysStudentBenefitExchangeList(asysStudentBenefitExchange);
        ExcelUtil<AsysStudentBenefitExchange> util = new ExcelUtil<AsysStudentBenefitExchange>(AsysStudentBenefitExchange.class);
        util.exportExcel(response, list, "学生作业减免权益兑换记录数据");
    }

    /**
     * 获取学生作业减免权益兑换记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:exchange:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(asysStudentBenefitExchangeService.selectAsysStudentBenefitExchangeById(id));
    }

    /**
     * 新增学生作业减免权益兑换记录
     */
    @PreAuthorize("@ss.hasPermi('system:exchange:add')")
    @Log(title = "学生作业减免权益兑换记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AsysStudentBenefitExchange asysStudentBenefitExchange)
    {
        return toAjax(asysStudentBenefitExchangeService.insertAsysStudentBenefitExchange(asysStudentBenefitExchange));
    }

    /**
     * 修改学生作业减免权益兑换记录
     */
    @PreAuthorize("@ss.hasPermi('system:exchange:edit')")
    @Log(title = "学生作业减免权益兑换记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AsysStudentBenefitExchange asysStudentBenefitExchange)
    {
        return toAjax(asysStudentBenefitExchangeService.updateAsysStudentBenefitExchange(asysStudentBenefitExchange));
    }

    /**
     * 删除学生作业减免权益兑换记录
     */
    @PreAuthorize("@ss.hasPermi('system:exchange:remove')")
    @Log(title = "学生作业减免权益兑换记录", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(asysStudentBenefitExchangeService.deleteAsysStudentBenefitExchangeByIds(ids));
    }
}
